<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../core/include.inc.jsp"%>

<style>
    .pageFormContent p {
        width: 90%;
    }
</style>

<div class="pageContent">
    <form method="post" action="role_edit" class="pageForm required-validate"
          onsubmit="return validateCallback(this, dialogAjaxDone)">

        <div class="pageFormContent nowrap" layoutH="57">
            <input type="hidden" name="id" readonly="readonly" value="${role.id}" />
            <p>
                <label>身份名称</label>
                <input type="text" name="roleName"
                       class="required" minlength="2" maxlength="20" value="${role.roleName}" />
            </p>
            <p>
                <label>分配权限</label>
                <div id="resultBox" />
                <ul class="tree treeFolder treeCheck expand" oncheck="getTreeStr" >
                    ${actTree}
                </ul>
                <input id="actTreeStr" type="hidden" name="actTreeStr" />
            </p>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent" style="text-align: center;">
                            <button type="submit" onclick="getTreeStr()">保存</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script type="text/javascript">
    function getTreeStr() {
        var result = "";
        var n = 0;
        $("div.ckbox.checked input").each( function( i ) {
            if ( n == 0 ) {
                result += $(this).attr( "value" );
            }else{
                result += "," + $(this).attr( "value" );
            }
            n++;
        } );

        $("div.ckbox.indeterminate input").each( function( i ) {
            if ( n == 0 ) {
                result += $(this).attr( "value" );
            }else{
                result += "," + $(this).attr( "value" );
            }
            n++;
        } );

        $("#actTreeStr").attr( "value", result );
    }
</script>